package #(package);

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import #(packageBase).business.service.#(className)Service;
import #(packageBase).common.core.controller.BaseController;
import #(packageBase).form.MsgInfoForm;
import #(packageBase).param.#(className)QueryParam;
import #(packageBase).vo.JsonResult;
import #(packageBase).vo.PageResult;
import #(packageBase).api.interfaces.#(className)ApiService;


import java.util.List;

/**
* #(comments) 接口
*
* @author #(author)
* @date #(datetime)
*/
@Api(value = "#(classname)", tags = "#(comments)相关接口")
@RestController
public class #(className)ApiController extends BaseController implements #(className)ApiService {

	@Autowired
	private #(className)Service #(classname)Service;

	@Override
	public JsonResult info(@PathVariable #(pk.attrType) #(pk.attrname)) {
        #(className) #(classname) = #(classname)Service.queryObject(#(pk.attrname));
        return JsonResult.ok(#(classname));
	}

	@Override
	public PageResult list(@RequestBody #(className)QueryParam #(classname)QueryParam) {
		//分页查询列表数据
		List<#(className)> #(classname)List = #(classname)Service.queryList(#(classname)QueryParam);
		return getPageData(#(classname)List);
	}

	@Override
	public JsonResult save(@RequestBody #(className)Form #(classname)Form) {
		#(className) #(classname) = #(classname)Form.toPo(#(className).class);
		return #(classname)Service.save(#(classname));
	}

	@Override
	public JsonResult update(@RequestBody #(className)Form #(classname)Form){
		#(className) #(classname) = #(classname)Form.toPo(#(className).class);
		return #(classname)Service.update(#(classname));
	}

	@Override
	public JsonResult delete(@PathVariable #(pk.attrType) #(pk.attrname)){
		return #(classname)Service.delete(#(pk.attrname));
	}

}
